package com.shareach.domain;

import java.util.Date;

import org.apache.commons.lang.StringUtils;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

@Document(collection = "baseCity")
public class BaseCityDomain {
	@Id
	private Long code;
	// 名称
	private String name;
	// 名称全拼
	private String py;
	// 点评编号
	private Integer dianping;
	// 号码区号
	private String tel;

	// 百度编号
	private Integer baidu;

	// 更新时间或者创建时间
	private Date updateTime = new Date();
	// 上架时间
	private Date deployTime;
	// 创建时间
	private Date creatTime;

	public Date getCreatTime() {
		return creatTime;
	}

	public void setCreatTime(Date creatTime) {
		this.creatTime = creatTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public Date getDeployTime() {
		return deployTime;
	}

	public void setDeployTime(Date deployTime) {
		this.deployTime = deployTime;
	}

	public Integer getBaidu() {
		return baidu;
	}

	public Integer getDianping() {
		return dianping;
	}

	public String getName() {
		return name;
	}

	public String getPy() {
		return py;
	}

	public String getTel() {
		return tel;
	}

	public void setBaidu(Integer baidu) {
		this.baidu = baidu;
	}

	public void setDianping(Integer dianping) {
		this.dianping = dianping;
	}

	public Long getCode() {
		return code;
	}

	public void setCode(Long code) {
		this.code = code;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setPy(String py) {
		this.py = py;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public BaseCityDomain compareTo(BaseCityDomain domain) {
		BaseCityDomain change = new BaseCityDomain();
		if (domain == null)
			return change;
		if (domain.getDianping() != null) {
			if (this.dianping == null || !this.dianping.equals(domain.getDianping())) {
				change.setDianping(domain.getDianping());
			}
		}
		if (domain.getBaidu() != null) {
			if (this.baidu == null || this.baidu.equals(domain.getBaidu())) {
				change.setBaidu(domain.getBaidu());
			}
		}
		if (StringUtils.isNotEmpty(domain.getPy())) {
			if (this.py == null || !this.py.trim().equals(domain.getPy().trim())) {
				change.setPy(domain.getPy().trim());
			}
		}
		if (StringUtils.isNotEmpty(domain.getTel())) {
			if (this.tel == null || !this.tel.trim().equals(domain.getTel())) {
				change.setTel(domain.getTel());
			}
		}
		if (StringUtils.isNotEmpty(domain.getName())) {
			if (this.name == null || this.name.trim().equals(domain.getName().trim())) {
				change.setName(domain.getName().trim());
			}
		}
		return change;
	}
}